home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / APW.SC / SC24Teach / Teach.asm / UMenu.asm < prev    next >
Encoding:
Assembly Source File  |  1990-06-24  |  15.3 KB  |  574 lines  |  [TEXT/pdos]

  1. ***********************************************************************
  2. *
  3. * teach umenu.aii -- Version 3.0 
  4. *
  5. * Copyright (c)
  6. * Apple Computer, Inc.  1986-1990
  7. * All Rights Reserved.
  8. *
  9. * Developer Technical Support Apple II Sample Code
  10. *
  11. * This file contains the code which implements  
  12. * windows in the busybox program.
  13. *
  14. ***********************************************************************
  15.  
  16.                case on
  17.  
  18.                copy 2/ainclude/e16.types
  19.                copy 2/ainclude/e16.event
  20.                copy 2/ainclude/e16.quickdraw
  21.                copy 2/ainclude/e16.textedit
  22.                copy teach.equ
  23.  
  24.                mcopy macros/umenu.macros
  25.  
  26.                longi on
  27.                longa on
  28.  
  29. ***********************************************************************
  30. * doQuitItem
  31. *
  32. * Just set the quitFlag -- that will do it.
  33. *
  34. doQuitItem     start
  35.  
  36.                inc quitFlag
  37.                rts
  38.  
  39.                end
  40.  
  41. ***********************************************************************
  42. * doAboutItem
  43. *
  44. * Display the vanity box.
  45. *
  46. doAboutItem    start
  47.  
  48.                pha
  49.                pea refIsResource*2
  50.                PushLong #0
  51.                PushLong #1
  52.                _AlertWindow
  53.                pla
  54.                rts
  55.  
  56.                end
  57.  
  58. ***********************************************************************
  59. * doSelectAll
  60. *
  61. * Tell TextEdit to select all the text for the front window.
  62. *
  63. doSelectAll    start
  64.  
  65.                DefineStack
  66.  
  67. thisHndl       long                     ;Must be at 1,s
  68.  
  69. saveDPage      word
  70. returnAddr     word
  71.  
  72. ******************
  73.  
  74.                phd                      ;Save directPage register.
  75.                pha                      ;Make space for thisHndl.
  76.                pha
  77.                tsc
  78.                tcd                      ;Set directPage register.
  79.  
  80.                pha                      ;Space for FrontWindow
  81.                pha
  82.                _FrontWindow
  83.                PushLong #MainWindowID   ;FrontWindow and MainWindowID
  84.                _GetCtlHandleFromID      ;are inputs for this.
  85. *                                       ;Result is now in thisHndl.
  86.  
  87.                PushLong #0
  88.                PushLong #$FFFFFFFF
  89.                pei thisHndl+2
  90.                pei thisHndl
  91.                _TESetSelection
  92.  
  93.                pla                      ;Remove space for thisHndl.
  94.                pla
  95.                pld                      ;Restore directPage register
  96.                rts
  97.  
  98.                end
  99.  
  100. ***********************************************************************
  101. * doChooseFont
  102. *
  103. * Use ChooseFont to select a different font, and then have TextEdit
  104. * change the selected text in the top window.
  105. *
  106. doChooseFont   start
  107.  
  108.                DefineStack
  109.  
  110. thisHndl       long                     ;Must be at 1,s
  111. thisStyle      block sizeofTEStyle
  112. tempHndl       long
  113.  
  114. stkFrameSize   EndLocals
  115.  
  116. saveDPage      word
  117. returnAddr     word
  118.  
  119. ******************
  120.  
  121.                phd                      ;Save directPage register.
  122.                tsc                      ;Make space for local variables.
  123.                sec
  124.                sbc #stkFrameSize
  125.                tcs
  126.                tcd                      ;Set directPage register.
  127.  
  128.                pha                      ;Create a temporary handle
  129.                pha                      ;for GetSelection style.
  130.                PushLong #20
  131.                PushWord userID
  132.                lda #0
  133.                pha                      ;word of 0.
  134.                pha                      ;long of 0.
  135.                pha
  136.                _NewHandle
  137.                pla
  138.                sta tempHndl
  139.                pla
  140.                sta tempHndl+2
  141.  
  142.                pha                      ;Space for FrontWindow
  143.                pha
  144.                _FrontWindow             ;FrontWindow and MainWindowID
  145.                PushLong #MainWindowID   ;are inputs for this.
  146.                _GetCtlHandleFromID      ;Result is now in thisHndl.
  147. *                                       ;This is the handle to the TE
  148. *                                       ;control for the top window.
  149.  
  150.                tsc                      ;Calculate pointer to thisStyle.
  151.                clc
  152.                adc #thisStyle
  153.                pha                      ;Result space.
  154.                pea 0                    ;Pointer to thisStyle.
  155.                pha
  156.                pei tempHndl+2
  157.                pei tempHndl
  158.                pei thisHndl+2
  159.                pei thisHndl
  160.                _TEGetSelectionStyle
  161.                pla
  162.  
  163.                pha                      ;Use it as the default
  164.                pha                      ;for ChooseFont.
  165.                pei thisStyle+teFont+2
  166.                pei thisStyle+teFont
  167.                pea 0
  168.                _ChooseFont
  169.                pla
  170.                sta thisStyle+teFont
  171.                pla
  172.                sta thisStyle+teFont+2
  173.  
  174.                tsc                      ;Calculate pointer to thisStyle.
  175.                clc
  176.                adc #thisStyle
  177.                pea teReplaceFont+teReplaceSize+teReplaceAttributes
  178.                pea 0                    ;Pointer to thisStyle.
  179.                pha
  180.                pei thisHndl+2
  181.                pei thisHndl
  182.                _TEStyleChange
  183.  
  184.                pei tempHndl+2
  185.                pei tempHndl
  186.                _DisposeHandle
  187.  
  188.                tsc                      ;Remove local space.
  189.                clc
  190.                adc #stkFrameSize
  191.                tcs
  192.                pld                      ;Restore directPage register.
  193.                rts
  194.  
  195.                end
  196.  
  197. ***********************************************************************
  198. * doSetFont
  199. *
  200. * Change the family number for the selected text for the top window.
  201. *
  202. doSetFont      start
  203.  
  204.                DefineStack
  205.  
  206. thisHndl       long                     ;Must be at 1,s
  207. thisStyle      block sizeofTEStyle
  208.  
  209. stkFrameSize   EndLocals
  210.  
  211. saveDPage      word
  212. returnAddr     word
  213.  
  214. theFam         word
  215.  
  216. ******************
  217.  
  218.                phd                      ;Save directPage register.
  219.                tsc
  220.                sec
  221.                sbc #stkFrameSize        ;Make space for local variables.
  222.                tcs
  223.                tcd                      ;Set directPage register.
  224.  
  225.                pha                      ;Space for FrontWindow
  226.                pha
  227.                _FrontWindow
  228.                PushLong #MainWindowID   ;FrontWindow and MainWindowID
  229.                _GetCtlHandleFromID      ;are inputs for this.
  230.  
  231.                lda theFam
  232.                sta thisStyle+teFont+ofamNum
  233.  
  234.                tsc                      ;Calculate pointer to thisStyle.
  235.                clc
  236.                adc #thisStyle
  237.                pea teReplaceFont
  238.                pea 0                    ;Pointer to thisStyle.
  239.                pha
  240.                pei thisHndl+2
  241.                pei thisHndl
  242.                _TEStyleChange
  243.  
  244.                tsc                      ;Remove local variable space.
  245.                clc
  246.                adc #stkFrameSize
  247.                tcs
  248.                pld                      ;Restore directPage register.
  249.                plx                      ;Keep return address.
  250.                pla                      ;Remove passed parameter.
  251.                phx                      ;Put return address back
  252.                rts                      ;and return.
  253.  
  254.                end
  255.  
  256. ***********************************************************************
  257. * doSetSize
  258. *
  259. * Change the font size for the selected text for the top window.
  260. *
  261. doSetSize      start
  262.  
  263.                DefineStack
  264.  
  265. thisHndl       long                     ;Must be at 1,s
  266. thisStyle      block sizeofTEStyle
  267.  
  268. stkFrameSize   EndLocals
  269.  
  270. saveDPage      word
  271. returnAddr     word
  272.  
  273. theSize        word
  274.  
  275. ******************
  276.  
  277.                phd                      ;Save directPage register.
  278.                tsc
  279.                sec
  280.                sbc #stkFrameSize        ;Make space for local variables.
  281.                tcs
  282.                tcd                      ;Set directPage register.
  283.  
  284.                pha                      ;Space for FrontWindow
  285.                pha
  286.                _FrontWindow
  287.                PushLong #MainWindowID   ;FrontWindow and MainWindowID
  288.                _GetCtlHandleFromID      ;are inputs for this.
  289.  
  290.                shortm
  291.                lda theSize
  292.                sta thisStyle+teFont+ofontSize
  293.                longm
  294.  
  295.                tsc                      ;Calculate pointer to thisStyle.
  296.                clc
  297.                adc #thisStyle
  298.                pea teReplaceSize
  299.                pea 0                    ;Pointer to thisStyle.
  300.                pha
  301.                pei thisHndl+2
  302.                pei thisHndl
  303.                _TEStyleChange
  304.  
  305.                tsc                      ;Remove local variable space.
  306.                clc
  307.                adc #stkFrameSize
  308.                tcs
  309.                pld                      ;Restore directPage register.
  310.                plx                      ;Keep return address.
  311.                pla                      ;Remove passed parameter.
  312.                phx                      ;Put return address back
  313.                rts                      ;and return.
  314.  
  315.                end
  316.  
  317. ***********************************************************************
  318. * doSetStyle
  319. *
  320. *
  321. doSetStyle     start
  322.  
  323.                DefineStack
  324.  
  325. thisHndl       long                     ;Must be at 1,s
  326. thisStyle      block sizeofTEStyle
  327.  
  328. stkFrameSize   EndLocals
  329.  
  330. saveDPage      word
  331. returnAddr     word
  332.  
  333. theStyle       word
  334.  
  335. ******************
  336.  
  337.                phd                      ;Save directPage register.
  338.                tsc
  339.                sec
  340.                sbc #stkFrameSize        ;Make space for local variables.
  341.                tcs
  342.                tcd                      ;Set directPage register.
  343.  
  344.                pha                      ;Space for FrontWindow
  345.                pha
  346.                _FrontWindow
  347.                PushLong #MainWindowID   ;FrontWindow and MainWindowID
  348.                _GetCtlHandleFromID      ;are inputs for this.
  349.  
  350.                shortm
  351.                lda theStyle
  352.                sta thisStyle+teFont+ofontStyle
  353.                longm
  354.  
  355.                ldx #teReplaceAttributes
  356.                lda theStyle
  357.                beq aa
  358.                ldx #teSwitchAttributes
  359. aa             tsc                      ;Calculate pointer to thisStyle.
  360.                clc
  361.                adc #thisStyle
  362.                phx                      ;Switch or replace.
  363.                pea 0                    ;Pointer to thisStyle.
  364.                pha
  365.                pei thisHndl+2
  366.                pei thisHndl
  367.                _TEStyleChange
  368.  
  369.                tsc                      ;Remove local variable space.
  370.                clc
  371.                adc #stkFrameSize
  372.                tcs
  373.                pld                      ;Restore directPage register.
  374.                plx                      ;Keep return address.
  375.                pla                      ;Remove passed parameter.
  376.                phx                      ;Put return address back
  377.                rts                      ;and return.
  378.  
  379.                end
  380.  
  381. ***********************************************************************
  382. * doMenu
  383. *
  384. * Function to handle all menu selections.  Examines the event.TaskData
  385. * menu item ID word from TaskMaster (from Event Manager) and calls the
  386. * appropriate routine.  While the routine is running the menu title is
  387. * still highlighted.  After the routine returns, we unhilight the
  388. * menu title.
  389. *
  390. doMenu         start
  391.  
  392.                lda event+owmTaskData
  393.                cmp #AboutItem
  394.                bne aa
  395.                jsr doAboutItem
  396.                brl exit
  397.  
  398. aa             cmp #CloseItem
  399.                bne ab
  400.                jsr doCloseTop
  401.                brl exit
  402.  
  403. ab             cmp #QuitItem
  404.                bne ac
  405.                jsr doQuitItem
  406.                brl exit
  407.  
  408. ac             cmp #SelectAllItem
  409.                bne ad
  410.                jsr doSelectAll
  411.                brl exit
  412.  
  413. ad             cmp #NewItem
  414.                bne ae
  415.                jsr doNewWindow
  416.                brl exit
  417.  
  418. ae             cmp #OpenItem
  419.                bne af
  420.                jsr doOpenWindow
  421.                brl exit
  422.  
  423. af             cmp #SaveItem
  424.                bne ag
  425.                jsr doSave
  426.                brl exit
  427.  
  428. ag             cmp #SaveAsItem
  429.                bne ah
  430.                jsr doSaveAs
  431.                brl exit
  432.  
  433. ah             cmp #PageSetupItem
  434.                bne ai
  435. *                                       ;Not implemented yet.
  436.                brl exit
  437.  
  438. ai             cmp #PrintItem
  439.                bne aj
  440. *                                       ;Not implemented yet.
  441.                brl exit
  442.  
  443. aj             cmp #PlainItem
  444.                bne ak
  445.                pea 0
  446.                jsr doSetStyle
  447.                brl exit
  448.  
  449. ak             cmp #BoldItem
  450.                bne al
  451.                pea boldMask
  452.                jsr doSetStyle
  453.                brl exit
  454.  
  455. al             cmp #ItalicItem
  456.                bne am
  457.                pea italicMask
  458.                jsr doSetStyle
  459.                brl exit
  460.  
  461. am             cmp #UnderlineItem
  462.                bne an
  463.                pea underlineMask
  464.                jsr doSetStyle
  465.                brl exit
  466.  
  467. an             cmp #ShadowItem
  468.                bne ao
  469.                pea shadowMask
  470.                jsr doSetStyle
  471.                brl exit
  472.  
  473. ao             cmp #OutlineItem
  474.                bne ap
  475.                pea outlineMask
  476.                jsr doSetStyle
  477.                brl exit
  478.  
  479. ap             cmp #Size8Item
  480.                bne aq
  481.                pea 8
  482.                jsr doSetSize
  483.                brl exit
  484.  
  485. aq             cmp #Size10Item
  486.                bne ar
  487.                pea 10
  488.                jsr doSetSize
  489.                brl exit
  490.  
  491. ar             cmp #Size12Item
  492.                bne as
  493.                pea 12
  494.                jsr doSetSize
  495.                brl exit
  496.  
  497. as             cmp #Size16Item
  498.                bne at
  499.                pea 16
  500.                jsr doSetSize
  501.                brl exit
  502.  
  503. at             cmp #Size20Item
  504.                bne au
  505.                pea 20
  506.                jsr doSetSize
  507.                brl exit
  508.  
  509. au             cmp #Size24Item
  510.                bne av
  511.                pea 24
  512.                jsr doSetSize
  513.                brl exit
  514.  
  515. av             cmp #ChooseFontItem
  516.                bne aw
  517.                jsr doChooseFont
  518.                brl exit
  519.  
  520. aw             cmp #FirstFontItem
  521.                bcc exit
  522.                pha                      ;Result space.
  523.                pha                      ;Item num.
  524.                _ItemID2FamNum           ;Fam num now on stack.
  525.                jsr doSetFont
  526.  
  527. exit           pea 0
  528.                lda event+owmTaskData+2
  529.                pha
  530.                _HiliteMenu
  531.  
  532.                rts
  533.  
  534.                end
  535.  
  536. ***********************************************************************
  537. * setupMenus
  538. *
  539. * Function to install our menu titles and their items in the system
  540. * menu bar and to redraw it so we can see them.
  541. *
  542. setupMenus     start
  543.  
  544.                pha
  545.                pha
  546.                pea refIsResource
  547.                PushLong #1
  548.                PushLong #0
  549.                _NewMenuBar2
  550.                _SetSysBar
  551.  
  552.                PushLong #0
  553.                _SetMenuBar
  554.  
  555.                pea AppleMenuID
  556.                _FixAppleMenu
  557.  
  558.                pea FontMenuID
  559.                pea FirstFontItem
  560.                pea 0
  561.                _FixFontMenu
  562.  
  563.                pha
  564.                _FixMenuBar
  565.                pla
  566.  
  567. * Rather than drawing menu bar here, I rely on FixFrontW to do it first.
  568.  
  569.                rts
  570.  
  571.                end
  572.  
  573.                END
  574.